inherited rstBuildings: TrstBuildings
  Left = 317
  Top = 186
  HelpContext = 1143
  ActiveControl = TfraAddress1.TownBox
  Caption = #1056#1077#1077#1089#1090#1088' '#1079#1076#1072#1085#1080#1081
  OnActivate = FormActivate
  PixelsPerInch = 96
  TextHeight = 13
  inherited Panel1: TPanel
    inherited TfraAddress1: TfraAddress
      Top = 0
      Height = 172
      inherited SearchBox: TGroupBox
        Height = 172
        Constraints.MinHeight = 0
        inherited SubPanel: TPanel
          Height = 155
          inherited Label6: TLabel
            Top = 174
            Visible = False
          end
          inherited Label7: TLabel
            Left = 42
            Caption = #1059#1087#1088#1072#1074#1083#1103#1102#1097#1072#1103' '#1082#1086#1084#1087#1072#1085#1080#1103
          end
          inherited Label5: TLabel
            Top = 171
            Visible = False
          end
          inherited Label4: TLabel
            Left = 14
            Top = 78
            Width = 126
            Alignment = taRightJustify
            Caption = #1059#1087#1088#1072#1074#1083#1103#1102#1097#1072#1103' '#1082#1086#1084#1087#1072#1085#1080#1103
          end
          inherited Label3: TLabel
            Left = 73
            Top = 58
          end
          inherited Label2: TLabel
            Left = 64
            Top = 34
          end
          inherited Label1: TLabel
            Left = 45
            Top = 10
          end
          inherited TownBox: TDBLookupComboboxEh
            Top = 7
            DropDownBox.SpecRow.CellsText = ' ---'
            DropDownBox.SpecRow.Value = 0
            TabOrder = 1
          end
          inherited StreetBox: TDBLookupComboboxEh
            Top = 31
            TabOrder = 2
          end
          inherited NLSEdit: TDBEditEh
            Left = 72
            Top = 168
            Visible = False
          end
          inherited NameEdit: TDBEditEh
            Top = 170
            TabOrder = 8
            Visible = False
          end
          inherited HouseBox: TDBLookupComboboxEh
            Top = 55
            TabOrder = 3
            OnKeyPress = TfraAddress1HouseBoxKeyPress
          end
          inherited FindBtn: TButton
            Top = 122
            Caption = #1055#1086#1080#1089#1082
            TabOrder = 5
          end
          inherited dbt2: TDBDateTimeEditEh
            TabOrder = 10
          end
          inherited dbt1: TDBDateTimeEditEh
            TabOrder = 11
          end
          inherited dbn2: TDBNumberEditEh
            TabOrder = 12
          end
          inherited dbn1: TDBNumberEditEh
            TabOrder = 13
          end
          inherited dbe2: TDBEditEh
            TabOrder = 14
          end
          inherited dbe1: TDBEditEh
            TabOrder = 15
          end
          inherited ClearBtn: TButton
            Top = 122
            TabOrder = 6
          end
          inherited AppartBox: TDBLookupComboboxEh
            Left = 16
            Top = 174
            Width = 234
            Height = 23
            TabStop = False
            TabOrder = 9
            Visible = False
          end
          inherited AddBtn: TButton
            Top = 122
            Enabled = False
            TabOrder = 7
          end
          inherited lcb1: TDBLookupComboboxEh
            Left = 14
            Top = 95
            Width = 236
            TabStop = True
            KeyField = 'ID'
            ListField = 'MANAG'
            ListSource = ds_QManag
            TabOrder = 4
            Visible = True
          end
        end
      end
      inherited QStreets: TpFIBDataSet
        Transaction = trList
        UpdateTransaction = trList
      end
      inherited QHouses: TpFIBDataSet
        Transaction = trList
        UpdateTransaction = trList
      end
      inherited QTowns: TpFIBDataSet
        Transaction = trList
        UpdateTransaction = trList
      end
      inherited QApparts: TpFIBDataSet
        Transaction = trList
        UpdateTransaction = trList
      end
    end
    inherited GroupBox1: TGroupBox
      Top = 172
      Height = 0
    end
    inherited TfraSubstanceInfo1: TfraSubstanceInfo
      Top = 172
      Height = 397
      inherited TopPanel: TPanel
        Height = 0
      end
      inherited BottomPanel: TPanel
        Top = 397
        Height = 0
      end
      inherited PageControl: TPageControl
        Top = 0
        Height = 397
        inherited TSInfo: TTabSheet
          inherited InfoGrid: TDBGridEh
            Height = 366
            OptionsEh = [dghFixed3D, dghHighlightFocus, dghClearSelection, dghDblClickOptimizeColWidth, dghDialogFind, dghColumnResize, dghColumnMove]
          end
        end
      end
      inherited QSubstanceInfo: TpFIBDataSet
        SelectSQL.Strings = (
          'SELECT'
          '    RFIELD_NAME as name,'
          '    RFIELD_VALUE as val'
          'FROM'
          '    PROC_BUILDING_GET_PROP_LIST(:ID) ')
        Transaction = trRefer
        UpdateTransaction = trRefer
        DataSource = dscRefer
        oFetchAll = True
      end
    end
  end
  inherited Panel2: TPanel
    inherited GroupBox2: TGroupBox
      Caption = ' '#1059#1089#1083#1091#1075#1080' '#1074' '#1079#1076#1072#1085#1080#1080' '
      inherited DetailGrid: TDBGridEh
        DataSource = dsc_Detail
        EvenRowColor = clInactiveCaptionText
        OptionsEh = [dghFixed3D, dghHighlightFocus, dghClearSelection, dghDblClickOptimizeColWidth, dghDialogFind, dghColumnResize, dghColumnMove]
        UseMultiTitle = True
        VTitleMargin = 5
        OnDblClick = DetailGridDblClick
        OnGetCellParams = DetailGridGetCellParams
        Columns = <
          item
            EditButtons = <>
            FieldName = 'DOGOVOR_ID'
            Footers = <>
            Visible = False
            WordWrap = True
          end
          item
            EditButtons = <>
            FieldName = 'SER_NAME'
            Footers = <>
            Width = 171
          end
          item
            EditButtons = <>
            FieldName = 'BALANCE'
            Footers = <>
          end
          item
            EditButtons = <>
            FieldName = 'SUPPLIER_NAME'
            Footers = <>
            Width = 252
          end
          item
            EditButtons = <>
            FieldName = 'RGROUP_ID'
            Footers = <>
            Visible = False
            WordWrap = True
          end
          item
            EditButtons = <>
            FieldName = 'RSUPPLIER_ID'
            Footers = <>
            Visible = False
            WordWrap = True
          end>
      end
    end
    inherited Panel3: TPanel
      inherited dbgRefer: TDBGridEh
        FooterRowCount = 1
        SumList.Active = True
        OnKeyDown = dbgReferKeyDown
        Columns = <
          item
            EditButtons = <>
            FieldName = 'ID'
            Footers = <>
            Visible = False
          end
          item
            EditButtons = <>
            FieldName = 'TOWN'
            Footers = <>
          end
          item
            EditButtons = <>
            FieldName = 'STREET'
            Footers = <>
          end
          item
            EditButtons = <>
            FieldName = 'HOUSE'
            Footers = <>
          end
          item
            EditButtons = <>
            FieldName = 'CORPS'
            Footers = <>
          end
          item
            EditButtons = <>
            FieldName = 'MANAG'
            Footers = <>
          end
          item
            EditButtons = <>
            FieldName = 'FULLSPACE'
            Footer.FieldName = 'FULLSPACE'
            Footer.ValueType = fvtSum
            Footers = <>
          end
          item
            EditButtons = <>
            FieldName = 'ABON_COUNT'
            Footer.FieldName = 'ABON_COUNT'
            Footer.ValueType = fvtSum
            Footers = <>
          end
          item
            EditButtons = <>
            FieldName = 'TEN_COUNT'
            Footer.FieldName = 'TEN_COUNT'
            Footer.ValueType = fvtSum
            Footers = <>
          end
          item
            EditButtons = <>
            FieldName = 'ZKX_NAME'
            Footers = <>
          end
          item
            EditButtons = <>
            FieldName = 'MATERIAL_NAME'
            Footers = <>
          end
          item
            EditButtons = <>
            FieldName = 'TOWN_ID'
            Footers = <>
            Visible = False
          end
          item
            EditButtons = <>
            FieldName = 'REGNUM'
            Footers = <>
          end>
      end
    end
  end
  inherited shblActionList: TActionList
    inherited aDelete: TAction
      Visible = False
    end
    inherited aPost: TAction
      Visible = False
    end
    inherited aRollback: TAction
      Visible = False
    end
    object aSearch: TAction
      Caption = #1048#1089#1082#1072#1090#1100
      Hint = #1048#1089#1082#1072#1090#1100
    end
    object aClear: TAction
      Caption = #1054#1095#1080#1089#1090#1080#1090#1100' '#1087#1072#1088#1072#1084#1077#1090#1088#1099' '#1087#1086#1080#1089#1082#1072
      Hint = #1054#1095#1080#1089#1090#1080#1090#1100' '#1087#1072#1088#1072#1084#1077#1090#1088#1099' '#1087#1086#1080#1089#1082#1072
    end
    object aAdvansedSearch: TAction
      Caption = #1056#1072#1089#1096#1080#1088#1077#1085#1085#1099#1081
      Hint = #1042#1099#1079#1074#1072#1090#1100' '#1092#1086#1088#1084#1091' '#1088#1072#1089#1096#1080#1088#1077#1085#1085#1086#1075#1086' '#1087#1086#1080#1089#1082#1072
    end
  end
  inherited dsRefer: TpFIBDataSet
    DeleteSQL.Strings = (
      'DELETE FROM'
      '    BUILDINGS'
      'WHERE'
      '        ID = :OLD_ID'
      '    ')
    RefreshSQL.Strings = (
      'select b.id, b.house, b.corps, b.regnum,'
      '       zk.name as zkx_name,'
      '       street,'
      '       r.name as material_name,'
      '       s.town_id,'
      '       t.name as town,'
      
        '       iif (exists(select first(1) 1 from vw_dogovors d, abonent' +
        's a'
      
        '              where d.abonent_id = a.id and a.building_id = b.id' +
        ' and a.client_id = -1)'
      
        '            or not exists(select first(1) 1 from dogovors d, abo' +
        'nents a'
      
        '              where d.abonent_id = a.id and a.building_id = b.id' +
        ' and a.client_id = -1),'
      
        '            (select sum((select count(1) from p_sel_abontenants_' +
        'by_period (a.id, current_date, current_date + 1)'
      '                    where status > 0))'
      '              from abonents a'
      '              where a.is_active = 1'
      '                and a.client_id >= 0'
      '                and a.building_id = b.id), null) as ten_count,'
      ''
      
        '       (select r.manag from rmanag r where r.id = b.owner_id) as' +
        ' manag,'
      '       (select a.id from abonents a'
      '          where a.client_id = -1'
      '            and a.building_id = b.id) as abonent_id,'
      ''
      '       (select count(1)'
      '          from abonents a'
      '          where a.is_active = 1'
      '            and a.client_id >= 0'
      '            and a.building_id = b.id) as abon_count'
      ''
      '  from pas_rtown t'
      '  join rstreets s on t.code = s.town_id'
      '  join buildings b on s.code = b.street_id'
      '  left join zkxs zk on zk.id = b.zkx_id'
      '  left join rmaterials r on r.id = b.material'
      '  where b.id = :ID'
      '     or b.id = :pbuilding_id '
      '')
    SelectSQL.Strings = (
      'select b.id, b.house, b.corps, b.regnum,'
      '       zk.name as zkx_name,'
      '       street,'
      '       r.name as material_name,'
      '       s.town_id,'
      '       t.name as town,'
      
        '       iif (exists(select first(1) 1 from vw_dogovors d, abonent' +
        's a'
      
        '              where d.abonent_id = a.id and a.building_id = b.id' +
        ' and a.client_id = -1)'
      
        '            or not exists(select first(1) 1 from dogovors d, abo' +
        'nents a'
      
        '              where d.abonent_id = a.id and a.building_id = b.id' +
        ' and a.client_id = -1),'
      
        '            (select sum((select count(1) from p_sel_abontenants_' +
        'by_period (a.id, current_date, current_date + 1)'
      '                    where status > 0))'
      '              from abonents a'
      '              where a.is_active = 1'
      '                and a.client_id >= 0'
      '                and a.building_id = b.id), null) as ten_count,'
      ''
      
        '       (select r.manag from rmanag r where r.id = b.owner_id) as' +
        ' manag,'
      '       (select a.id from abonents a'
      '          where a.client_id = -1'
      '            and a.building_id = b.id) as abonent_id,'
      ''
      '       (select count(1)'
      '          from abonents a'
      '          where a.is_active = 1'
      '            and a.client_id >= 0'
      '            and a.building_id = b.id) as abon_count,'
      ''
      '       (select sum(a.occ_fullspace)'
      '          from abonents a'
      '          where a.is_active = 1'
      '            and a.client_id >= 0'
      '            and a.building_id = b.id) as fullspace'
      ''
      '  from pas_rtown t'
      '  join rstreets s on t.code = s.town_id'
      '  join buildings b on s.code = b.street_id'
      '  left join zkxs zk on zk.id = b.zkx_id'
      '  left join rmaterials r on r.id = b.material'
      '  where (s.town_id = :ptown_id or coalesce(:ptown_id, 0) <= 0)'
      '    and (s.code = :pstreet_id or coalesce(:pstreet_id, 0) <= 0)'
      
        '    and (b.id = :pbuilding_id or coalesce(:pbuilding_id, 0) <= 0' +
        ')'
      
        '    and (b.owner_id = :pmanag_id or coalesce(:pmanag_id, -1) < 0' +
        ')'
      '')
    AutoUpdateOptions.UpdateTableName = 'BUILDINGS'
    AutoUpdateOptions.KeyFields = 'ID'
    Database = MAINDM.pMainDatabase
    object dsReferID: TFIBIntegerField
      FieldName = 'ID'
      Visible = False
    end
    object dsReferHOUSE: TFIBStringField
      DisplayLabel = #8470' '#1076#1086#1084#1072
      DisplayWidth = 10
      FieldName = 'HOUSE'
      Size = 16
      EmptyStrToNull = True
    end
    object dsReferCORPS: TFIBStringField
      DisplayLabel = #1050#1086#1088#1087'.'
      DisplayWidth = 5
      FieldName = 'CORPS'
      Size = 3
      EmptyStrToNull = True
    end
    object dsReferREGNUM: TFIBStringField
      DisplayLabel = #1050#1072#1076#1072#1089#1090#1088#1086#1074#1099#1081' '#8470
      FieldName = 'REGNUM'
      Size = 16
      EmptyStrToNull = True
    end
    object dsReferZKX_NAME: TFIBStringField
      DisplayLabel = #1059#1095#1072#1089#1090#1086#1082
      DisplayWidth = 15
      FieldName = 'ZKX_NAME'
      Size = 255
      EmptyStrToNull = True
    end
    object dsReferSTREET: TFIBStringField
      DisplayLabel = #1059#1083#1080#1094#1072
      DisplayWidth = 20
      FieldName = 'STREET'
      Size = 120
      EmptyStrToNull = True
    end
    object dsReferMATERIAL_NAME: TFIBStringField
      DisplayLabel = #1052#1072#1090#1077#1088#1080#1072#1083' '#1089#1090#1077#1085
      DisplayWidth = 15
      FieldName = 'MATERIAL_NAME'
      Size = 60
      EmptyStrToNull = True
    end
    object dsReferTOWN_ID: TFIBIntegerField
      DefaultExpression = '1'
      FieldName = 'TOWN_ID'
      Visible = False
    end
    object dsReferTOWN: TFIBStringField
      DisplayLabel = #1053#1072#1089#1077#1083#1077#1085#1085#1099#1081' '#1087#1091#1085#1082#1090
      DisplayWidth = 15
      FieldName = 'TOWN'
      Size = 60
      EmptyStrToNull = True
    end
    object dsReferTEN_COUNT: TFIBBCDField
      DisplayLabel = #1050#1086#1083'-'#1074#1086' '#1078#1080#1083#1100#1094#1086#1074
      FieldName = 'TEN_COUNT'
      Size = 0
      RoundByScale = True
    end
    object dsReferMANAG: TFIBStringField
      DisplayLabel = #1046#1080#1083#1080#1097#1085#1072#1103' '#1086#1088#1075#1072#1085#1080#1079#1072#1094#1080#1103
      DisplayWidth = 20
      FieldName = 'MANAG'
      Size = 60
      EmptyStrToNull = True
    end
    object dsReferABONENT_ID: TFIBIntegerField
      FieldName = 'ABONENT_ID'
      Visible = False
    end
    object dsReferABON_COUNT: TFIBIntegerField
      DisplayLabel = #1051#1080#1094#1077#1074#1099#1093' '#1089#1095#1077#1090#1086#1074
      FieldName = 'ABON_COUNT'
    end
    object dsReferFULLSPACE: TFIBBCDField
      DisplayLabel = #1054#1073#1097#1072#1103' '#1087#1083#1086#1097#1072#1076#1100
      DisplayWidth = 16
      FieldName = 'FULLSPACE'
      Size = 3
      RoundByScale = True
    end
  end
  inherited trRefer: TpFIBTransaction
    Top = 280
  end
  object ds_Detail: TpFIBDataSet [10]
    SelectSQL.Strings = (
      'SELECT'
      '    DOGOVOR_ID,'
      '    SER_NAME,'
      '    BALANCE,'
      '    SUPPLIER_NAME,'
      '    RGROUP_ID,'
      '    RSUPPLIER_ID,'
      '    IS_ACTIVE'
      'FROM'
      '    PROC_ABONDOGOVORS_GET_S((select a.id from abonents a'
      '          where a.client_id = -1'
      '            and a.building_id = :id)) ')
    Transaction = trRefer
    Database = MAINDM.pMainDatabase
    DataSource = dscRefer
    Left = 36
    Top = 484
    WaitEndMasterScroll = True
    dcForceOpen = True
    oFetchAll = True
    object ds_DetailDOGOVOR_ID: TFIBIntegerField
      FieldName = 'DOGOVOR_ID'
      Visible = False
    end
    object ds_DetailSER_NAME: TFIBStringField
      DisplayLabel = #1059#1089#1083#1091#1075#1072
      DisplayWidth = 20
      FieldName = 'SER_NAME'
      Size = 120
      EmptyStrToNull = True
    end
    object ds_DetailBALANCE: TFIBBCDField
      DisplayLabel = #1057#1072#1083#1100#1076#1086
      FieldName = 'BALANCE'
      Size = 2
      RoundByScale = True
    end
    object ds_DetailSUPPLIER_NAME: TFIBStringField
      DisplayLabel = #1055#1086#1089#1090#1072#1074#1097#1080#1082
      DisplayWidth = 20
      FieldName = 'SUPPLIER_NAME'
      Size = 60
      EmptyStrToNull = True
    end
    object ds_DetailRGROUP_ID: TFIBIntegerField
      FieldName = 'RGROUP_ID'
    end
    object ds_DetailRSUPPLIER_ID: TFIBIntegerField
      FieldName = 'RSUPPLIER_ID'
    end
    object ds_DetailIS_ACTIVE: TFIBIntegerField
      FieldName = 'IS_ACTIVE'
    end
  end
  object dsc_Detail: TDataSource [11]
    DataSet = ds_Detail
    Left = 72
    Top = 484
  end
  object QManag: TpFIBDataSet [12]
    SelectSQL.Strings = (
      
        'select cast(-1 as integer) as id, cast('#39' ---- '#39' as varchar(60)) ' +
        'as manag from rdb$database'
      'union'
      'select id, manag'
      '  from rmanag '
      '  order by 2'
      '')
    Transaction = trList
    Database = MAINDM.pMainDatabase
    Left = 602
    Top = 76
    oFetchAll = True
    object QManagID: TFIBIntegerField
      FieldName = 'ID'
    end
    object QManagMANAG: TFIBStringField
      FieldName = 'MANAG'
      Size = 60
      EmptyStrToNull = True
    end
  end
  object ds_QManag: TDataSource [13]
    DataSet = QManag
    Left = 638
    Top = 76
  end
  inherited PropStorage: TPropStorageEh
    Section = 'rstBuildings'
    StoredProps.Strings = (
      '<P>.Height'
      '<P>.Left'
      '<P>.PixelsPerInch'
      '<P>.Top'
      '<P>.Width'
      '<P>.WindowState'
      'Panel2.GroupBox2.<P>.Height'
      'Panel2.GroupBox2.DetailGrid.<P>.Columns.ColumnsIndex'
      'Panel2.GroupBox2.DetailGrid.<P>.Columns.<ForAllItems>.Width'
      'Panel2.Panel3.dbgRefer.<P>.Columns.ColumnsIndex'
      'Panel2.Panel3.dbgRefer.<P>.Columns.<ForAllItems>.Width')
  end
  inherited trList: TpFIBTransaction
    TPBMode = tpbReadCommitted
  end
end
